﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms.DataVisualization.Charting;
using System.Diagnostics;
using System.Drawing;
using System.Data;

namespace SecurityDev
{
    sealed class WindowsCharting
    {
#pragma warning disable 0628
        protected internal Chart GenerateChart(DataTable table, int width, int height, string bgColor, string intType,string[] arr)
        {
            Chart chart = new Chart();
            chart.Width = width;
            chart.Height = height;

            chart.DataSource = table;

            ChartArea chartArea = new ChartArea();
            chartArea.AxisX.LabelAutoFitMaxFontSize = 12;
            chartArea.AxisX.LabelStyle.Font = new Font("Verdana", 12, FontStyle.Bold);
            chart.ChartAreas.Add(chartArea);

            string series = "Series1";
            chart.Series.Add(series);
            chart.Series[series].XValueMember = arr[0];            
            chart.Series[series].YValueMembers = arr[1];
            chart.Series[series].ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), intType);
            
            chart.DataBind();
            
            return chart;
        }
    }
}
